package com.rzj.book.service.impl;

import com.rzj.book.bo.UserBO;
import com.rzj.book.dao.IUserDao;
import com.rzj.book.en.User;
import com.rzj.book.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author Administrator
 * @Date 2020/5/14 20:53
 * @Version 1.0
 */
@Service
@Transactional
public class UserServiceImpl implements IUserService {

    @Autowired
    private IUserDao userDao;

    @Override
    public List<User> findAll() throws Exception {
        return userDao.findAll();
    }

    @Override
    public List<User> findByPage(UserBO userBO, Integer page, Integer pageSize) {
        page = (page -1 ) * pageSize;
        return userDao.findByPage(userBO,page,pageSize);
    }

    @Override
    public Integer findByPageCount(UserBO userBO, Integer page, Integer pageSize) {
        page = (page -1 ) * pageSize;
        return userDao.findByPageCount(userBO,page,pageSize);
    }

    @Override
    public User getUserById(Integer id) {
        return userDao.getUserById(id);
    }

    @Override
    public void addUser(User user) {
        userDao.addUser(user);
    }

    @Override
    public void updateUser(User user) {
        userDao.updateUser(user);
    }

    @Override
    public void deleteUser(Integer id) {
        userDao.deleteUser(id);
    }

    @Override
    public User findByUsername(String userName) {
        return  userDao.findByUsername(userName);
    }

    @Override
    public User login(String userName, String pwd) {
        return userDao.login(userName,pwd);
    }
}
